/* gettimeofday函数使用示例 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

int main(void)
{
	struct timeval tval;
	int ret;

	ret = gettimeofday(&tval, NULL);
	if (-1 == ret) {
		perror("gettimeofday error");
		exit(-1);
	}

	printf("时间值: %ld秒 + %ld微秒\n", tval.tv_sec, tval.tv_usec);
	exit(0);
}
